<?php

class WechatMsgTemplate
{


    /*
     *  礼品退回通知-电子券24小时后未领取退回的微信信息
     *  {{first.DATA}}
            名称：{{keyword1.DATA}}
            原因：{{keyword2.DATA}}
            号码：{{keyword3.DATA}}
            密码：{{keyword4.DATA}}
            有效期：{{keyword5.DATA}}
            {{remark.DATA}}
     */
    public static function coupon_return($template_id,$openid, $url, $coupon_name,$reson, $coupon_no, $pwd, $validdate,$first='',$remark='')
    {
        $data = array(
            "touser" => $openid,
            "template_id" => $template_id,
            "url" => $url,
            "miniprogram" => array(
                "appid" => "",
                "pagepath" => ""
            ),
            "data" => array(
                "first" => array(
                    "value" => $first,
                    // "color" => "#173177"
                ),
                "keyword1" => array(
                    "value" => $coupon_name,
                    // "color" => "#173177"
                ),
                "keyword2" => array(
                    "value" => $reson,
                    // "color" => "#173177"
                ),
                "keyword3" => array(
                    "value" => $coupon_no,
                    // "color" => "#173177"
                ),
                "keyword4" => array(
                    "value" => $pwd,
                    // "color" => "#173177"
                ),
                "keyword5" => array(
                    "value" => $validdate,
                    // "color" => "#173177"
                ),
                "remark" => array(
                    "value" => $remark,
                    //  "color" => "#173177"
                ),
            )
        );
        return $data;
    }

    /**
     * @param $first
     * @param $PushInfo 推送信息数组
     * @param $remark   备注
     * @param $template_id 微信模板ID
     * @param $openid 接收者openid
     * @param $url  点击地址
     * @return array
     */
    public static function coupon_recevive($first,$PushInfo,$remark,$template_id, $openid, $url)
    {
        $data = array(
            "touser" => $openid,
            "template_id" => $template_id,
            "url" => $url,
            "miniprogram" => array(
                "appid" => "",
                "pagepath" => ""
            ),
            "data" => array(
                "first" => array(
                    "value" => $first,
                ),
                "keyword1" => array(
                    "value" => $PushInfo['keyword1'],
                ),
                "keyword2" => array(
                    "value" => $PushInfo['keyword2'],
                ),
                "keyword3" => array(
                    "value" => $PushInfo['keyword3'],
                ),
                "keyword4" => array(
                    "value" => $PushInfo['keyword4'],
                ),
                "remark" => array(
                    "value" => $remark,
                ),
            )
        );
        return $data;
    }

    /**
     * @param $first
     * @param $PushInfo 推送信息数组
     * @param $remark   备注
     * @param $template_id 微信模板ID
     * @param $openid 接收者openid
     * @param $url  点击地址
     * @return array
     */
    public static function pushTimeOut($first,$PushInfo,$remark,$template_id, $openid, $url)
    {
        $data = array(
            "touser" => $openid,
            "template_id" => $template_id,
            "url" => $url,
            "miniprogram" => array(
                "appid" => "",
                "pagepath" => ""
            ),
            "data" => array(
                "first" => array(
                    "value" => $first,
                ),
                "keyword1" => array(
                    "value" => $PushInfo['keyword1'],
                ),
                "keyword2" => array(
                    "value" => $PushInfo['keyword2'],
                ),
                "keyword3" => array(
                    "value" => $PushInfo['keyword3'],
                ),
                "remark" => array(
                    "value" => $remark,
                ),
            )
        );
        return $data;
    }


    public static function PushRidersSingle($template_id,$openid, $url, $receiver_name, $coupon_name, $receiver_time)
    {
        $data = array(
            "touser" => $openid,
            "template_id" => $template_id,
            "url" => $url,
            "miniprogram" => array(
                "appid" => "",
                "pagepath" => ""
            ),
            "data" => array(
                "first" => array(
                    "value" => "您的元祖电子券已赠送成功，以下是领取人信息，请查阅。",
                ),
                "keyword1" => array(
                    "value" => $receiver_name,
                ),
                "keyword2" => array(
                    "value" => $coupon_name,
                ),
                "keyword3" => array(
                    "value" => $receiver_time,
                ),
                "remark" => array(
                    "value" => "更多电子券信息查阅请点击下面详情。",
                ),
            )
        );
        return $data;
    }



        /*
         *  订单支付成功
         * {{first.DATA}}
            订单编号：{{keyword1.DATA}}
            支付金额：{{keyword2.DATA}}
            {{remark.DATA}}
         */
    public static function payment_finish($template_id,$openid, $url, $orderno, $paid_amount)
    {
        $data = array(
            "touser" => $openid,
            "template_id" => $template_id,
            "url" => $url,
            "miniprogram" => array(
                "appid" => "",
                "pagepath" => ""
            ),
            "data" => array(
                "first" => array(
                    "value" => "您的订单已支付成功，我们会尽快为您发货。",
                ),
                "keyword1" => array(
                    "value" => $orderno,
                ),
                "keyword2" => array(
                    "value" => $paid_amount,
                ),
                "remark" => array(
                    "value" => "详细请见元祖微商城。",
                ),
            )
        );
        return $data;
    }
    
    /*
     * 抽奖推送消息
     * {{first.DATA}}
     * 参与者：{{keyword1.DATA}}
     * 活动名称：{{keyword2.DATA}}
     * 时间：{{keyword3.DATA}}
     * {{remark.DATA}}
     */
    public static function draw_push($template_id,$openid, $url, $member_name, $draw_name, $starttime, $endtime){
        $data = array(
            "touser" => $openid,
            "template_id" => $template_id,
            "url" => $url,
            "miniprogram" => array(
                "appid" => "",
                "pagepath" => ""
            ),
            "data" => array(
                "first" => array(
                    "value" => "恭喜您，获得一次抽奖机会。",
                ),
                "keyword1" => array(
                    "value" => $member_name,
                ),
                "keyword2" => array(
                    "value" => $draw_name,
                ),
                "keyword3" => array(
                    "value" => $starttime .'~'. $endtime,
                ),
                "remark" => array(
                    "value" => "赶快点击下面详情参与抽奖吧，丰厚奖品等着您！",
                ),
            )
        );
        return $data;
    }

    /*
         *  待支付订单提醒
         * {{first.DATA}}
            商品详情：{{keyword1.DATA}}
            待付金额：{{keyword2.DATA}}
            交易单号：{{keyword3.DATA}}
            交易时间：{{keyword4.DATA}}
            交易有效期：{{keyword5.DATA}}
            {{remark.DATA}}
         */
    public static function unpaid($template_id,$openid, $url, $products, $paid_amount, $order_no, $order_time, $validate)
    {
        $data = array(
            "touser" => $openid,
            "template_id" => $template_id,
            "url" => $url,
            "miniprogram" => array(
                "appid" => "",
                "pagepath" => ""
            ),
            "data" => array(
                "first" => array(
                    "value" => "您提交了商品订单，正等待支付中",
                ),
                "keyword1" => array(
                    "value" => $products,
                ),
                "keyword2" => array(
                    "value" => $paid_amount,
                ),
                "keyword3" => array(
                    "value" => $order_no,
                ),
                "keyword4" => array(
                    "value" => $order_time,
                ),
                "keyword5" => array(
                    "value" => $validate,
                ),

                "remark" => array(
                    "value" => "请及时支付订单，逾期失效",
                ),
            )
        );
        return $data;
    }


    public static function getTemplate($template_id,$openid, $url, $first, $remark, $keywords)
    {
        $data = array(
            "touser" => $openid,
            "template_id" => $template_id,
            "url" => $url,
            "miniprogram" => array(
                "appid" => "",
                "pagepath" => ""
            ),
            "data" => array(
                "first" => array(
                    "value" => $first,
                ),
                "remark" => array(
                    "value" => $remark,
                ),
            )
        );
        if (!empty($keywords)){
            foreach($keywords as $k=>$value){
                $data['data'][$value['key']]=array("value"=>$value['value']);
            }
        }
        return $data;
    }









}

?>
